package com.ws.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.ws.dao.UserDao;
import com.ws.entity.User;
import com.ws.service.LoginService;

@Component("clientLoginServiceImpl")
public class ClientLoginServiceImpl implements LoginService {
	
	private UserDao userDao;
	
	@Resource(name="userDaoImpl")
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public String doLogin(String username,String password) {
		List<User> userList=new ArrayList<User>();
		userList=userDao.getObjectList();
		for(int i=0;i<userList.size();i++){
			if(username.equals(userList.get(i).getUserName()) && 
					password.equals(userList.get(i).getUserPwd())){
				return "success";
			}
		}
		return "error";
	}

}
